<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // Rest 
    // 扩展运算符和解构赋值配合使用   => 
    // 数组: 将剩余的元素整合起来放到数组中
    // 对象: 将剩余的键值对整合起来放到新对象中

    // 注意:  Rest元素必须是最后一个元素

    // 扩展运算符 和 数组解构
    // var [a,b,...c] = [1,2,3,4,5,6];
    // // a=>1  b=>2  ...c => 3,4,5,6
    // console.log(a,b,c);  // 1 2 [3,4,5,6]

    // 报错:  Uncaught SyntaxError: Rest element must be last element
    // var [a,b,...c,d] = [1,2,3,4,5,6];  
    // a=>1  b=>2  ...c => 3,4,5    d=>6
    // console.log(a,b,c,d);

     // 扩展运算符 和 对象解构

    //  var {a,b,...o} = {a:1,b:2,c:3,d:4,e:5,f:6}
    // // a => 1   b => 2    ...o => c:3,d:4,e:5,f:6
    // console.log(a,b,o);

    // 报错:  Uncaught SyntaxError: Rest element must be last element
    // var {a,b,...o,f} = {a:1,b:2,c:3,d:4,e:5,f:6}
    // // a => 1   b => 2    ...o => c:3,d:4,e:5,f:6
    // console.log(a,b,o);


    var {a,b,f,...o} = {a:1,b:2,c:3,d:4,e:5,f:6}
    // a => 1   b => 2   f=>6  ...o => c:3,d:4,e:5,f:6
    console.log(a,b,o,f);


</script>
</html>